package com.zys.el.user.aspect;


import com.zys.el.user.service.ITargetService;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class TimeAspect {

    @Autowired
    private ITargetService targetService;
//    @AfterReturning("execution(* java.lang.Long.. com.zys.el.user.service. )")
//    public Object after(ProceedingJoinPoint pj) {
//        return null;
//    }


//    @AfterReturning(value = "execution(* com.zys.el.user.service.ITargetService+.*(..))", returning = "result")
//    public Object afterReturn(Object result) {
//        if (result != null) {
//            Long res = (Long) result;
//            System.out.println("result:" + res);
////            if (res.size() == 0) {
////                result = false;
////            }
//            targetService.getById((Long) result);
////            System.out.println("target:" + target);
////            Date date = new Date();
////            target.setUpdateTime(date);
////            targetService.saveOrUpdate(target);
////            System.out.println("Date:" + date);
//        }
//        System.out.println("后置通知：在目标方法执行之后被调用的通知,result=" + result);
//        return result;
//    }

//    @Before(value = "execution(* com.zys.el.user.service.ITargetService+.*(..))")
//    public Object[] before(JoinPoint jp) {
//        System.out.println("前置通知：在目标方法执行之前被调用的通知");
//        String name = jp.getSignature().getName();
//        System.out.println("拦截的方法名称：" + name);
//        Object[] args = jp.getArgs();
//        System.out.println("方法的参数格式：" + args.length);
//        System.out.println("方法参数列表：");
//        for (Object arg : args) {
//            if (arg.getClass().equals(Target.class)) {
//                System.out.println("\t" + arg);
//                ((Target) arg).setDelete(0);
//                ((Target) arg).setUpdateTime(new Date());
//            }
//            System.out.println("\t" + arg);
//        }
//        return args;
//    }

}
